import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/nurse_user_bill/nurseUserBill/list',
  save='/nurse_user_bill/nurseUserBill/add',
  edit='/nurse_user_bill/nurseUserBill/edit',
  deleteOne = '/nurse_user_bill/nurseUserBill/delete',
  deleteBatch = '/nurse_user_bill/nurseUserBill/deleteBatch',
  importExcel = '/nurse_user_bill/nurseUserBill/importExcel',
  exportXls = '/nurse_user_bill/nurseUserBill/exportXls',
  nurseUserBillDetailList = '/nurse_user_bill/nurseUserBill/listNurseUserBillDetailByMainId',
  nurseUserBillDetailSave='/nurse_user_bill/nurseUserBill/addNurseUserBillDetail',
  nurseUserBillDetailEdit='/nurse_user_bill/nurseUserBill/editNurseUserBillDetail',
  nurseUserBillDetailDelete = '/nurse_user_bill/nurseUserBill/deleteNurseUserBillDetail',
  nurseUserBillDetailDeleteBatch = '/nurse_user_bill/nurseUserBill/deleteBatchNurseUserBillDetail',
  nurseUserBillInvoiceList = '/nurse_user_bill/nurseUserBill/listNurseUserBillInvoiceByMainId',
  nurseUserBillInvoiceSave='/nurse_user_bill/nurseUserBill/addNurseUserBillInvoice',
  nurseUserBillInvoiceEdit='/nurse_user_bill/nurseUserBill/editNurseUserBillInvoice',
  nurseUserBillInvoiceDelete = '/nurse_user_bill/nurseUserBill/deleteNurseUserBillInvoice',
  nurseUserBillInvoiceDeleteBatch = '/nurse_user_bill/nurseUserBill/deleteBatchNurseUserBillInvoice',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
/**
 * 列表接口
 * @param params
 */
export const nurseUserBillDetailList = (params) => {
  if(params['billId']){
    return defHttp.get({url: Api.nurseUserBillDetailList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserBillDetailDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserBillDetailDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserBillDetailDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserBillDetailDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserBillDetailSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserBillDetailEdit : Api.nurseUserBillDetailSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserBillDetailImportUrl = '/nurse_user_bill/nurseUserBill/importNurseUserBillDetail'

/**
 * 导出
 */
export const nurseUserBillDetailExportXlsUrl = '/nurse_user_bill/nurseUserBill/exportNurseUserBillDetail'
/**
 * 列表接口
 * @param params
 */
export const nurseUserBillInvoiceList = (params) => {
  if(params['billId']){
    return defHttp.get({url: Api.nurseUserBillInvoiceList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const nurseUserBillInvoiceDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.nurseUserBillInvoiceDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const nurseUserBillInvoiceDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.nurseUserBillInvoiceDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  nurseUserBillInvoiceSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.nurseUserBillInvoiceEdit : Api.nurseUserBillInvoiceSave;
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const nurseUserBillInvoiceImportUrl = '/nurse_user_bill/nurseUserBill/importNurseUserBillInvoice'

/**
 * 导出
 */
export const nurseUserBillInvoiceExportXlsUrl = '/nurse_user_bill/nurseUserBill/exportNurseUserBillInvoice'
